package com.demo.ex02.entity;

import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;//EJB3
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.persistence.Version;

import com.demo.util.Sex;

@Entity
@Table(name="t_user")
public class User {
	
	private Long id;
	private String userName;
	private String password;
	
	private Integer version;
	
	private Date date;
	private Sex sex;
	
	private String longText1;
	private byte[] fullCode;


	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}
	
	//@Basic//(fetch=FetchType.EAGER)
	//@Basic(fetch=FetchType.LAZY)
	@Column(length=20,name="",unique=true,nullable=false)
	public String getUserName() {
		return userName;
	}
	
	//@Transient
	@Column(length=20,nullable=false)
	public String getPassword() {
		return password;
	}
	
	@Version//乐观锁
	public Integer getVersion() {
		return version;
	}
	
//	@Temporal(TemporalType.DATE)
	@Temporal(TemporalType.TIME)
//	@Temporal(TemporalType.TIMESTAMP)
	public Date getDate() {
		return date;
	}

//	@Enumerated(EnumType.ORDINAL)
//	@Enumerated(EnumType.STRING)
	public Sex getSex() {
		return sex;
	}
	@Lob
	public String getLongText1() {
		return longText1;
	}
	@Lob
	public byte[] getFullCode() {
		return fullCode;
	}

	public void setId(Long id) {
		this.id = id;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	public void setVersion(Integer version) {
		this.version = version;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public void setSex(Sex sex) {
		this.sex = sex;
	}

	public void setLongText1(String longText1) {
		this.longText1 = longText1;
	}

	public void setFullCode(byte[] fullCode) {
		this.fullCode = fullCode;
	}

	@Override
	public String toString() {
		return "User [id=" + id + ", userName=" + userName + ", password=" + password + ", version=" + version
				+ ", date=" + date + ", sex=" + sex + "]";
	}

	
	
}
